<!--
 * @Author: 杨光辉(GerhardYang)
 * @Date: 2021-10-15 10:01:32
 * @LastEditors: 杨光辉(GerhardYang)
 * @LastEditTime: 2022-03-25 13:39:29
 * @Description: file content
 * @Copyright: 超图软件华中平台客户中心 (SuperMap Software Co., Ltd. -Central China Platform)
-->
<template>
  <div>
    <a-time-picker
      placeholder="开始时间"
      v-model="startTime"
      :default-value="moment('07:00', 'HH:mm')"
      @change="changestart"
      format="HH:mm"
    />
    <a-time-picker
      placeholder="结束时间"
      v-model="endTime"
      format="HH:mm"
      :default-value="moment()"
      @change="changeend"
    />
    <span style="margin-left: 10px; margin-right: 10px">
      <a-button type="primary" @click="searchTrack()">二次查询</a-button>
    </span>
  </div>
</template>
<script>
import moment from "moment";
import services from "@/services/api";

export default {
  data() {
    return {
      startTime: null,
      endTime: null,
    };
  },

  mounted() {
    console.log(this.secondsearchInfo);
    this.startTime = this.secondsearchInfo.defultstartTime;
    this.endTime = moment();
  },
  props: ["secondsearchInfo"],
  methods: {
    moment,
    changestart() {},
    changeend() {},
    setSearchParam() {
      let querybody = {};
      let starttime = [];
      let endtime = [];
      starttime[1] = this.startTime.format("HH:mm:ss").toString();
      endtime[1] = this.endTime.format("HH:mm:ss").toString();
      starttime[0] = this.secondsearchInfo.startDate
        .format("YYYY-MM-DD")
        .toString();
      endtime[0] = this.secondsearchInfo.endDate
        .format("YYYY-MM-DD")
        .toString();
      console.log(endtime, starttime);
      querybody = {
        vehicleNo: this.secondsearchInfo.vehicleNo,
        plateColor: this.secondsearchInfo.plateColor,
        startTime: starttime[0] + " " + starttime[1],
        endTime: endtime[0] + " " + endtime[1],
      };
      return querybody;
    },
    searchTrack() {
      let param = this.setSearchParam();
      let self = this;
      services
        .searchVehicleTrack(param)
        .then((res) => {
          console.log("车辆轨迹数据", res);
          if (res.tollList.length == 0) {
            self.$message.info("未查询到轨迹数据");
            return;
          }
          self.$emit("child-event", res.tollList);
        })
        .catch((err) => {
          self.$message.info("查询失败");
          console.log("error", err);
        });
    },
  },
};
</script>

<style></style>
